<?php slot('herramientas') ?>
	<?php echo jq_link_to_remote(__('Nuevo'), array(
    		'update' => 'emergente',
    		'url'    => 'parte/new'),
    		array('class' =>'tool_nuevo')
	) ?>
	<span class="tool_eliminar"><?php echo __('Eliminar')?></span>
	<span class="tool_imprimir"><?php echo __('Imprimir')?></span>
	<span class="tool_buscar"><?php echo __('Buscar')?></span>
        <?php if (count($sf_user->getAttribute('parte.filters'))!=0): ?>
	   <?php echo link_to(__('Listar todos'), 'parte/filter', array('query_string' => '_reset', 'method' => 'post', 'class' => 'tool_todos')) ?>
	<?php endif; ?>
        <span class="tool_presupuestar"><?php echo __('Presupuestar')?></span>
        <span class="tool_facturar"><?php echo __('Facturar')?></span>


	<script language="JavaScript" type="text/javascript">
  	$(function() {
  		var filtrar = function () {
                    if ($("#crm_parte_filters_cliente_vehiculo").val()==""){
                        $('#crm_parte_filters_cliente_id').val("");
                    }
                    $('#formFiltrar').submit();
  		};
  		var cancelar = function () {
  			$('#formFiltrar').append('<input type="hidden" name="_reset"/>');
			$('#formFiltrar').submit();
  		};
  		var dialogOpts = {
  			autoOpen: false,
  			width:520,
  			height:450,
  			closeOnEscape: true,
  			modal: true,
  			buttons: {
  				"<?php echo __("Filter")?>": filtrar,
  				"<?php echo __("Cancel")?>": cancelar
  			},
  			open: function() {
      			//$(this).parents('.ui-dialog-buttonpane button:eq(0)').focus();
    		}
  		};
  		$('#crm_filtro').keyup(function(e) {
    		if (e.keyCode == 13) {
        		$('#formFiltrar').submit();
    		}
		});
  		$("#crm_filtro").dialog(dialogOpts);


  		$('.tool_eliminar').click(function() {
  						  $("#batch_action").attr('value', 'batchDelete');
 						  $('#acciones').submit();
	  	});
		$('.tool_imprimir').click(function() {
  						  $("#batch_action").attr('value', 'batchPrint');
 						  $('#acciones').submit();
	  	});
  		$(".tool_nuevo").button({
            icons: {
                primary: "ui-icon-plusthick"
            },
            text: true
        });
        $(".tool_buscar").button({
            icons: {
                primary: "ui-icon-search"
            },
            text: true
        }).click(function () {
			($("#crm_filtro").dialog("isOpen") == false) ?
				$("#crm_filtro").dialog("open") : $("#crm_filtro").dialog("close");
        });
        $(".tool_imprimir").button({
            icons: {
                primary: "ui-icon-print"
            },
            text: true
        });
        $('.tool_presupuestar').click(function() {
  						  $("#batch_action").attr('value', 'batchPresupuestar');
 						  $('#acciones').submit();
	});
        $(".tool_facturar").button({
            icons: {
                primary: "ui-icon-circle-check"
            },
            text: true
        });
                $('.tool_facturar').click(function() {
  						  $("#batch_action").attr('value', 'batchFacturar');
 						  $('#acciones').submit();
	});
        $(".tool_presupuestar").button({
            icons: {
                primary: "ui-icon-circle-check"
            },
            text: true
        });
        $(".tool_eliminar").button({
            icons: {
                primary: "ui-icon-minusthick"
            },
            text: true
        });
        $(".tool_listar_producto").button({
            icons: {
                primary: "ui-icon-script"
            },
            text: true
        });
         $(".tool_todos").button({
            icons: {
                primary: "ui-icon-script"
            },
            text: true
        });
	});
  </script>
<?php end_slot() ?>